package com.dhcc.bpm.modules.alarm.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.modules.alarm.entity.Alarm;
import com.dhcc.bpm.modules.alarm.mapper.AlarmMapper;
import com.dhcc.bpm.modules.alarm.service.IAlarmService;
import com.dhcc.bpm.modules.alarm.vo.AlarmVO;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description 告警表 服务实现类
 * @Author sjm
 * @Date 2020/2/21 0021 15:16
 * @Version V1.0
 * @Copyright: 2020 东华软件 . All rights reserved.
 **/
@Service
public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, Alarm> implements IAlarmService {
	@Autowired
	private AlarmMapper alarmMapper;
	/**
	 * @Description 分页查询
	 * @Author xiafayu
	 * @Date 2020/2/24 17:30
	 * @param page
	 * @param alarm
	 * @return com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.alarm.vo.AlarmVO>
	 **/
	@Override
	public IPage<AlarmVO> selectAlarmPage(IPage<AlarmVO> page, AlarmVO alarm) {
		// 若不使用mybatis-plus自带的分页方法，则不会自动带入tenantId，所以我们需要自行注入
		//alarm.setTenantId(SecureUtil.getTenantId());
		return page.setRecords(baseMapper.selectAlarmPage(page, alarm));
	}

	/**
	 * @Description 分页查询
	 * @Author xiafayu
	 * @Date 2020/2/24 17:30
	 * @param map
	 * @return java.util.List<com.dhcc.bpm.modules.alarm.entity.Alarm>
	 **/
	@Override
	public List<Alarm> selectByIds(Map<String, Object> map) {
		return baseMapper.selectByIds(map);
	}

	/**
	 * @Description 分页查询
	 * @Author xiafayu
	 * @Date 2020/2/24 17:30
	 * @param map
	 * @return java.util.List<com.dhcc.bpm.modules.alarm.entity.Alarm>
	 **/
	@Override
	public List<Alarm> selectByPrdtIds(Map<String, Object> map) {
		return baseMapper.selectByPrdtIds(map);
	}
	/**
	 * 更新状态
	 * @param alarm
	 * @return
	 */
	@Override
	public int  updateRefreshFlag(Alarm alarm){
		return  alarmMapper.updateRefreshFlag(alarm);
	}
}
